<%-- 
    Document   : product
    Created on : Jul 6, 2011, 1:31:01 PM
    Author     : ThanhToan
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="dao.ProductDAO" %>
<%@ page import="dao.CategoriesDAO" %>
<%@ page import="model.ProductModel" %>
<%@ page import="model.CategoriesModel" %>
<%@page import="java.util.ArrayList"%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Product Page</title>
        <script type="text/javascript" language="JavaScript"></script>
    </head>
    <body>
	<div id="main_container">
		<!-- S HEAD CONTENT -->
			<jsp:include page="block/header.jsp" />
		<!-- E HEAD CONTENT -->

		<!-- S Top Menu -->
			<jsp:include page="block/top_menu.jsp" />
		<!-- E Top Menu -->

                <!-- S Navigation -->
			<jsp:include page="block/navigation.jsp" />
		<!-- E Navigation -->

                <!-- S Left Menu -->
			<jsp:include page="block/left_menu.jsp" />
		<!-- E Left Menu -->

		<!-- S Body Content -->
                <form action="<%=request.getContextPath()%>/ProductController" method="post" id="sortProduct" name="sortProduct">
                    <table cellpadding="0" cellspacing="0" border="0" align="center">
                        <tr>
                            <td>
                                <label style="font-size:medium" > Catogories :  </label>
                            </td>
                            <td>
                                <select name="cboCategories" id="cboCategories" onchange="">
                                    <option value=""> ------------------ </option>
                                    <c:forEach var="objCategories" items="<%= CategoriesDAO.getAllCategories() %>">
                                        <option value="${objCategories.id}" <c:if test="">selected</c:if>>${objCategories.cateName}</option>
                                    </c:forEach>
                                </select>
                            </td>
                        </tr>
                    </table>
                </form>
                <br/>
                <form action="<%=request.getContextPath()%>/ProductController" method="post" id="product" name="product">
                    <table cellpadding="" cellspacing="0" border="1" align="center">
                        <tr style="height: 50px; background-color:teal ">
                            <td></td>
                            <td align="center"><h3>Image</h3></td>
                            <td align="center"><h3>ProductName</h3></td>
                            <td align="center"><h3>Categories</h3></td>
                            <td align="center"><h3>Description</h3></td>
                            <td align="center"><h3>Price(USD)</h3></td>
                            <td style="width: 35px" align="center"></td>
                        </tr>
                        <% int count = 1; %>
			<c:set var="iterator" value="<%=count%>"></c:set>
                        <c:forEach var="objProduct" items="<%= ProductDAO.getAllProduct() %>">
                            <tr>
                                <td style="width: 15px;" align="center">${iterator}</td>
                                <td style="width: 237px; height: 140px">
                                    <img src="${objProduct.image}" alt="" border="0" />
                                </td>
                                <td align="center" >${objProduct.proName}</td>
                                <td align="center">${objProduct.cateName}</td>
                                <td>${objProduct.proDes}</td>
                                <td align="center">${objProduct.price}</td>
                                <td align="center"> <a href="productDetail.jsp?${objProduct.id}">Edit</a> </td>
                            </tr>
                            <c:set var="iterator" value="${iterator+1}"></c:set>
                        </c:forEach>
                    </table>
                </form>
		<!-- E Body Content -->
	</div>
    </body>
</html>
